package cn.livingCloud.dto;

import cn.livingCloud.entity.core.CaseComments;
import cn.livingCloud.entity.core.Employee;
import cn.livingCloud.entity.user.Member;
import cn.livingCloud.entity.user.User;
import cn.livingCloud.utils.DateUtils;

/**
 * Created by 唐旭 on 2016/6/3.
 */
public class CaseCommentDto {
    private String uuid;
    private String caseUuid;
    private Boolean disable = false;
    private String content;
    private String createDateTime;
    /**
     * 留言用户
     */
    private String userUuid;
    private String memberUuid;
    /**
     * 回复员工
     */
    private String employeeUuid;

    private MemberDto memberDto;

    private EmployeeDto employeeDto;

    private UserDto userDto;

    public CaseCommentDto() {
    }

    public CaseCommentDto(CaseComments comment) {
        this.uuid = comment.getUuid();
        this.caseUuid = comment.getCaseUuid();
        this.disable = comment.getDisable();
        this.content = comment.getContent();
        this.userUuid = comment.getUserUuid();
        this.memberUuid = comment.getMemberUuid();
        this.employeeUuid = comment.getEmployeeUuid();
        Member member = comment.getMember();
        if (member != null) {
            this.memberDto = new MemberDto(member);
        }
        Employee employee = comment.getEmployee();
        if (employee != null) {
            this.employeeDto = new EmployeeDto(employee);
        }
        User user = comment.getUser();
        if (user != null) {
            this.userDto = new UserDto(user);
        }
        this.createDateTime = DateUtils.toDateText(comment.getCreateDateTime()
                , DateUtils.DEFAULT_DATE_TIME_FORMAT);
    }

    public String getMemberUuid() {
        return memberUuid;
    }

    public CaseCommentDto setMemberUuid(String memberUuid) {
        this.memberUuid = memberUuid;
        return this;
    }

    public String getCaseUuid() {
        return caseUuid;
    }

    public CaseCommentDto setCaseUuid(String caseUuid) {
        this.caseUuid = caseUuid;
        return this;
    }

    public String getContent() {
        return content;
    }

    public CaseCommentDto setContent(String content) {
        this.content = content;
        return this;
    }

    public String getCreateDateTime() {
        return createDateTime;
    }

    public CaseCommentDto setCreateDateTime(String createDateTime) {
        this.createDateTime = createDateTime;
        return this;
    }

    public Boolean getDisable() {
        return disable;
    }

    public CaseCommentDto setDisable(Boolean disable) {
        this.disable = disable;
        return this;
    }

    public EmployeeDto getEmployeeDto() {
        return employeeDto;
    }

    public CaseCommentDto setEmployeeDto(EmployeeDto employeeDto) {
        this.employeeDto = employeeDto;
        return this;
    }

    public String getEmployeeUuid() {
        return employeeUuid;
    }

    public CaseCommentDto setEmployeeUuid(String employeeUuid) {
        this.employeeUuid = employeeUuid;
        return this;
    }

    public MemberDto getMemberDto() {
        return memberDto;
    }

    public CaseCommentDto setMemberDto(MemberDto memberDto) {
        this.memberDto = memberDto;
        return this;
    }

    public UserDto getUserDto() {
        return userDto;
    }

    public CaseCommentDto setUserDto(UserDto userDto) {
        this.userDto = userDto;
        return this;
    }

    public String getUserUuid() {
        return userUuid;
    }

    public CaseCommentDto setUserUuid(String userUuid) {
        this.userUuid = userUuid;
        return this;
    }

    public String getUuid() {
        return uuid;
    }

    public CaseCommentDto setUuid(String uuid) {
        this.uuid = uuid;
        return this;
    }

    public String getName() {
        if (userDto != null) {
            return userDto.getName();
        }
        if (memberDto != null) {
            return memberDto.getNickname();
        }
        if (employeeDto != null) {
            return employeeDto.getName();
        }
        return "无昵称";
    }

    @Override
    public String toString() {
        return "CaseCommentDto{" +
                "caseUuid='" + caseUuid + '\'' +
                ", uuid='" + uuid + '\'' +
                ", disable=" + disable +
                ", content='" + content + '\'' +
                ", createDateTime='" + createDateTime + '\'' +
                ", userUuid='" + userUuid + '\'' +
                ", memberUuid='" + memberUuid + '\'' +
                ", employeeUuid='" + employeeUuid + '\'' +
                ", memberDto=" + memberDto +
                ", employeeDto=" + employeeDto +
                ", userDto=" + userDto +
                '}';
    }
}
